PasswordGenerator.generate   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 17
rs 9.9
c 0
b 0
f 0
cc 2
1
import Generator from './Base';
2
3
/**
4
 * Generates a random password.
5
 * @description uppercase/lowercase alpha combined with numbers, 10-24 symbols
6
 * @returns {string} password
7
 * @requires int
8
 * @requires pick
9
 * @generator
10
 */
11
export default class PasswordGenerator extends Generator {
12
    generate() {
13
        const alphabet = [
14
            ...'abcdefghijklmnopqrstuvwxyz',  // eslint-disable-line no-secrets/no-secrets
15
            ...'ABCDEFGHIJKLMNOPQRSTUVWXYZ',  // eslint-disable-line no-secrets/no-secrets
16
            ...'0123456789'
17
        ];
18
19
        // eslint-disable-next-line no-magic-numbers
20
        const len = this.fatum.int(10, 24);
21
        const word = [];
22
23
        for (let i = 0; i < len; i++) {
24
            word.push(this.fatum.pick(alphabet));
25
        }
26
27
        return word.join('');
28
    }
29
}
30